local fangjie = fk.CreateSkill {
    name = "gai__fangjie",
    tags = { Skill.Limited }
  }
  
  Fk:loadTranslationTable{
    ["gai__fangjie"] = "芳洁",
    [":gai__fangjie"] = "限定技，准备阶段，若你没有“蓄谋”牌，你回复1点体力并摸一张牌，然后重置此技能，否则你可以弃置任意张你区域里的“蓄谋”牌；获得“谮毁”并失去“魅步”。",
  
    ["#gai__fangjie-ask"] = "芳洁：是否弃置任意张“蓄谋”牌；获得“谮毁”并失去“魅步”？",
  }
  
  fangjie:addEffect(fk.EventPhaseStart, {
    anim_type = "support",
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill(fangjie.name) and player.phase == Player.Start and player:usedSkillTimes(fangjie.name, Player.HistoryGame) == 0
    end,
    on_cost = function (self, event, target, player, data)
      local room = player.room
      local cards = table.filter(player:getCardIds("j"), function (id)
        return player:getVirtualEquip(id) and player:getVirtualEquip(id).name == "premeditate"
      end)
      if #cards == 0 then
        event:setCostData(self, {choice = "recover"})
        return true
      else
        cards = room:askToCards(player, {
          min_num = 1,
          max_num = #cards,
          include_equip = false,
          skill_name = fangjie.name,
          pattern = tostring(Exppattern{ id = cards }),
          prompt = "#gai__fangjie-ask",
          cancelable = true,
          expand_pile = cards,
        })
        if #cards > 0 then
          event:setCostData(self, {choice = "discard", cards = cards})
          return true
        end
      end
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      local choice = event:getCostData(self).choice
      if choice == "recover" then
        if player:isWounded() then
          room:recover{
            who = player,
            num = 1,
            recoverBy = player,
            skillName = fangjie.name,
          }
          if player.dead then return end
        end
        player:drawCards(1, fangjie.name)
        player:setSkillUseHistory("gai__fangjie", 0, Player.HistoryGame)
      else
        room:throwCard(event:getCostData(self).cards, fangjie.name, player, player)
        room:handleAddLoseSkills(player, "-ty__meibu|ol_ex__zenhui")
      end
    end,
  })
  
  return fangjie